
const user = {
  state: {
		userInfo:JSON.parse(localStorage.getItem('userInfo')==""?null:localStorage.getItem('userInfo')),
    windowSize:'',
  },

  mutations: {
    SET_userInfo: (state, userInfo) => {
      state.userInfo = userInfo
    },
    SET_window_size: (state, windowSize) => {
      state.windowSize = windowSize
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_ROLES: (state, roles) => {
      state.roles = roles
    }
  },

  actions: {//异步操作mutation
    // 登录
    set_Login_info({ commit }, userInfo) {
      localStorage.setItem('userInfo', JSON.stringify(userInfo));
      commit('SET_userInfo', userInfo)
    },

    //监听窗口大小
    set_window_size({commit},windowSize) {
			console.log('mmm',windowSize)
      commit('SET_window_size', windowSize)
    },

    // 登出
		set_LogOut({ commit }, userInfo) {
			localStorage.setItem('userInfo', "");
      // localStorage.clear()
      commit('SET_userInfo', userInfo)
    },
  }
}

export default user
